package com.EAIPClub.CodeShellManager.controller;

import com.EAIPClub.CodeShellManager.service.CodeShellManagerService;
import com.api.POJO.CodeLab.CodeShellManager.CodeShellManagerReturnMsg;
import com.api.POJO.UserDataManager.Data.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Description :
 * @Author :
 * @Date : 2021/12/6
 */
@RestController
public class CodeShellManagerController {

    private CodeShellManagerService service;

    @Autowired
    public void setService(CodeShellManagerService service) {
        this.service = service;
    }

    @GetMapping("/codeshell/apply/{token}")
    public CodeShellManagerReturnMsg applyForResource(@PathVariable String token) {
        return service.applyForResource(token);
    }

    @GetMapping("/codeshell/set/{session}")
    public CodeShellManagerReturnMsg setWebSocketSession(@PathVariable String session) {
        return service.setWebSocketSession(session);
    }

    @GetMapping("/codeshell/close/{session}")
    public CodeShellManagerReturnMsg closeWebSocketSession(@PathVariable String session) {
        return service.closeWebSocketSession(session);
    }

    @GetMapping("/codeshell/get/useruid/{useruid}")
    public CodeShellManagerReturnMsg getCodeShellHostInfoByUserUid(@PathVariable String useruid){
        return service.getCodeShellHostByUserUid(useruid);
    }
}
